package com.yanqu.road.entity.activity.foxcard;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.DataStatus;
import com.yanqu.road.entity.FieldTypeAnnotation;

import java.util.ArrayList;
import java.util.List;

@FieldTypeAnnotation(tableName = "t_u_activity_fox_shop", desc = "狐妖小红娘商店数据")
public class UserFoxCardShop extends DataObject {
    @FieldTypeAnnotation(select = true, isIndex = true, update = true)
    private int activityId;
    @FieldTypeAnnotation(desc = "玩家id", select = true, isIndex = true, update = true)
    private long userId;
    @FieldTypeAnnotation(desc = "销售卡牌")
    private List<FoxSaleCard> saleCards = new ArrayList<>(); //销售卡牌
    @FieldTypeAnnotation(desc = "已刷新次数")
    private int refreshAmount; //已刷新次数
    @FieldTypeAnnotation(desc = "刷新价格")
    private int refreshPrice; //刷新价格
    @FieldTypeAnnotation(desc = "免费的次数")
    private int freeTimes;
    @FieldTypeAnnotation(desc = "可以刷到的效果牌")
    private List<Integer> inPoolCardIds = new ArrayList<>(); //可以刷到的效果牌
    @FieldTypeAnnotation(desc = "刷掉的效果牌")
    private List<Integer> outPoolCardIds = new ArrayList<>(); //刷掉的效果牌
    @FieldTypeAnnotation(desc = "优惠券")
    private FoxSaleCard coupon; //优惠券
    @FieldTypeAnnotation(desc = "卡包")
    private List<FoxCardPack> cardPacks = new ArrayList<>(); //卡包

    public UserFoxCardShop(int activityId, long userId) {
        this.activityId = activityId;
        this.userId = userId;
        setInsertOption();
    }

    public UserFoxCardShop() {
    }

    public int getActivityId() {
        return activityId;
    }
    public void setActivityId(int activityId) {
        if (this.activityId != activityId) {
            this.activityId = activityId;
            setOp(DataStatus.Update);
        }
    }

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        if (this.userId != userId) {
            this.userId = userId;
            setOp(DataStatus.Update);
        }
    }

    public java.util.List<com.yanqu.road.entity.activity.foxcard.FoxSaleCard> getSaleCards() {
        return saleCards;
    }

    public void setSaleCards(java.util.List<com.yanqu.road.entity.activity.foxcard.FoxSaleCard> saleCards) {
        if (null == saleCards) {
            return;
        }
        if (this.saleCards == null || !this.saleCards.equals(saleCards)) {
            this.saleCards = saleCards;
            setOp(DataStatus.Update);
        }
    }

    public int getRefreshAmount() {
        return refreshAmount;
    }

    public void setRefreshAmount(int refreshAmount) {
        if (this.refreshAmount != refreshAmount) {
            this.refreshAmount = refreshAmount;
            setOp(DataStatus.Update);
        }
    }

    public int getRefreshPrice() {
        return refreshPrice;
    }

    public void setRefreshPrice(int refreshPrice) {
        if (this.refreshPrice != refreshPrice) {
            this.refreshPrice = refreshPrice;
            setOp(DataStatus.Update);
        }
    }

    public int getFreeTimes() {
        return freeTimes;
    }

    public void setFreeTimes(int freeTimes) {
        if (this.freeTimes != freeTimes) {
            this.freeTimes = freeTimes;
            setUpdateOption();
        }
    }

    public java.util.List<java.lang.Integer> getInPoolCardIds() {
        return inPoolCardIds;
    }

    public void setInPoolCardIds(java.util.List<java.lang.Integer> inPoolCardIds) {
        if (null == inPoolCardIds) {
            return;
        }
        if (this.inPoolCardIds == null || !this.inPoolCardIds.equals(inPoolCardIds)) {
            this.inPoolCardIds = inPoolCardIds;
            setOp(DataStatus.Update);
        }
    }

    public java.util.List<java.lang.Integer> getOutPoolCardIds() {
        return outPoolCardIds;
    }

    public void setOutPoolCardIds(java.util.List<java.lang.Integer> outPoolCardIds) {
        if (null == outPoolCardIds) {
            return;
        }
        if (this.outPoolCardIds == null || !this.outPoolCardIds.equals(outPoolCardIds)) {
            this.outPoolCardIds = outPoolCardIds;
            setOp(DataStatus.Update);
        }
    }

    public FoxSaleCard getCoupon() {
        return coupon;
    }

    public void setCoupon(FoxSaleCard coupon) {
        if (this.coupon == null || coupon == null || !this.coupon.equals(coupon)) {
            this.coupon = coupon;
            setOp(DataStatus.Update);
        }
    }

    public java.util.List<com.yanqu.road.entity.activity.foxcard.FoxCardPack> getCardPacks() {
        return cardPacks;
    }

    public void setCardPacks(java.util.List<com.yanqu.road.entity.activity.foxcard.FoxCardPack> cardPacks) {
        if (null == cardPacks) {
            return;
        }
        if (this.cardPacks == null || !this.cardPacks.equals(cardPacks)) {
            this.cardPacks = cardPacks;
            setOp(DataStatus.Update);
        }
    }

    public UserFoxCardShop clone() {
        UserFoxCardShop shop = new UserFoxCardShop();
        for (FoxSaleCard saleCard : this.getSaleCards()) {
            shop.getSaleCards().add(saleCard.clone());
        }
        shop.setRefreshAmount(this.getRefreshAmount());
        shop.setRefreshPrice(this.getRefreshPrice());
        shop.setInPoolCardIds(new ArrayList<>(this.getInPoolCardIds()));
        shop.setOutPoolCardIds(new ArrayList<>(this.getOutPoolCardIds()));
        shop.setFreeTimes(this.getFreeTimes());
        if (this.getCoupon() != null){
            shop.setCoupon(this.getCoupon().clone());
        }
        for (FoxCardPack cardPack : this.getCardPacks()) {
            shop.getCardPacks().add(cardPack.clone());
        }
        return shop;
    }

    public void copy(UserFoxCardShop copyShop) {
        this.saleCards = copyShop.getSaleCards();
        this.refreshAmount = copyShop.getRefreshAmount();
        this.refreshPrice = copyShop.getRefreshPrice();
        this.inPoolCardIds = copyShop.getInPoolCardIds();
        this.outPoolCardIds = copyShop.getOutPoolCardIds();
        this.coupon = copyShop.getCoupon();
        this.cardPacks = copyShop.getCardPacks();
        this.freeTimes = copyShop.freeTimes;
        if (copyShop.isUpdateOption()) {
            this.setUpdateOption();
        }
    }
}
